<?php

/*
 * @description   文件上传方法
 * @author widuu  http://www.widuu.com
 * @mktime 08/01/2014
 */

global $QINIU_ACCESS_KEY;
global $QINIU_SECRET_KEY;

$QINIU_UP_HOST	= 'http://up.qiniu.com';
$QINIU_RS_HOST	= 'http://rs.qbox.me';
$QINIU_RSF_HOST	= 'http://rsf.qbox.me';

//配置$QINIU_ACCESS_KEY和$QINIU_SECRET_KEY 为你自己的key
$QINIU_ACCESS_KEY	= 'xeV_RrHiZ5jds-CrnHveF6BaruC4ZKaXBQvOo_Oa';
$QINIU_SECRET_KEY	= 'PfN1_-cXLoEtbwJHRJ1Sf9LsIcUl-kqdulJ2BiJI';

//配置bucket为你的bucket
$BUCKET = "cloud-test";

//配置你的域名访问地址
// $HOST  = config('qiniu.DOMAIN');
$HOST  = 'http://ovjm6oszs.bkt.clouddn.com';
//上传超时时间
$TIMEOUT = "3600";

//保存规则
$SAVETYPE = "Qiniu";

//开启水印
$USEWATER = false;
$WATERIMAGEURL = ""; //七牛上的图片地址
//水印透明度
$DISSOLVE = 50;
//水印位置
$GRAVITY = "SouthEast";
//边距横向位置
$DX  = 10;
//边距纵向位置
$DY  = 10;

function urlsafe_base64_encode($data){
	$find = array('+', '/');
	$replace = array('-', '_');
	return str_replace($find, $replace, base64_encode($data));
}

function getWebConfig(){
    $config = [];
    if(!empty($_GET['token'])){
        $name = md5($_GET['token']);
        $filename = $_SERVER['DOCUMENT_ROOT'].'/../data/' . $name . '.php';
        if (!is_file($filename)) {
            $config['web_id'] = 0;
        }else{
            $content = file_get_contents($filename);
            if (false !== $content) {
                $content = substr($content, 20, -3);
                $content = unserialize($content);
                $config['web_id'] = $content['web_id']??0;
            } else {
               $config['web_id'] = 0;
            }
        }
    }
    $config['module'] = $_GET['module']??'other';
    $config['prefix'] = "yaliapi/{$config['web_id']}/{$config['module']}/";
    return $config;
}

